<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:s="http://sduept.security.el/func"
	template="/template/template.xhtml">
	<ui:define name="head">
		<title>#{request.getParameter('selectName')} 定检计划分析</title>
			<link rel="stylesheet" href="#{request.contextPath}/resources/plugins/datatables/dataTables.bootstrap.css" />
			<link rel="stylesheet" href="/resources/bootstrap/css/bootstrap-datetimepicker.min.css" />
		<style>
.dataTable th {
	white-space: nowrap !important;
}

#WrapProtectTimeLine {
	height: 60px;
	padding-top: 20px;
}s
</style>
	</ui:define>
	<ui:define name="content">
		<div class='full-center-content-scroll-noheader'>
			<div id="WrapProtectTimeLine" class="col-sm-12 col-lg-12">
				<h:form>
					<p:remoteCommand name="selectYear" actionListener="#{checkPlanMaintenanceController.selectYear}" />
				</h:form>
				<p:outputLabel value="选择年份 ：" />
				<input type="text" id="year" onchange="changeYear()" style="width:60px;text-align:center" />
				
				<!-- <h:selectOneMenu value="#{checkPlanMaintenanceController.year}"
					id="year_id" style="width:100px;margin-right:20px;height:30px">
					<f:selectItems value="#{checkPlanMaintenanceController.years}" />
				</h:selectOneMenu> -->
				
				<p:outputLabel value="选择月份 ：" style="margin-left:10px;"/>
				<h:selectOneMenu value="#{checkPlanMaintenanceController.month}"
					id="month_id" style="width:80px;margin-right:20px;height:30px">
					<f:selectItems value="#{checkPlanMaintenanceController.months}" />
					<f:selectItem itemLabel="全年" itemValue="全年" />
				</h:selectOneMenu>
				<p:commandButton id="searchBtn" value="查询" icon="ui-icon-search"
					style="margin-right:10px" oncomplete="initDatas()" />
				<p:commandButton id="resetBtn" value="重置" icon="ui-icon-refresh"
					style="margin-right:10px"
					actionListener="#{checkPlanMaintenanceController.getCurrentYearAndMonth()}"
					oncomplete="refresh()" update="month_id" />
				<p:commandButton value="数据维护" icon="ui-icon-document"
					oncomplete="PF('dataDlg').show()" update="form"
					process="@this"
					actionListener="#{checkPlanMaintenanceController.initCondition()}"
					rendered="#{s:hasPermission(session,'tjfx_bhdjfx_sjwh')}" />
			</div>
			<div class="nav-tabs-custom">
				<div class="tab-content no-padding">
					<div class="chart tab-pane active" id="yearCase"
						style="position: relative">
						<div class="row">
							<div class="col-xs-12">
								<div class="box box-primary">
									<div class="box-header with-border">
										<h4 id="linebarid" class='box-title' ></h4>
									</div>
									<div class="box-body">
										<div id="checkbar" style="height: 400px; margin: 0 auto;text-align:center;color:grey;font-size:16px;font-weight:bold" />
									</div>
								</div>
							</div>
							<div class="col-xs-12">
								<div class="col-lg-6 col-xs-6 no-padding">
									<div class="box box-primary ">
										<div class="box-header with-border">
											<h4 id="pieid" class='box-title'></h4>
										</div>
										<div class="box-body">
											<div id="checkpie" style="height: 350px; margin: 0 auto;text-align:center;color:grey;font-size:16px;font-weight:bold" />
										</div>
									</div>
								</div>
								<div class="col-lg-6 col-xs-6 no-padding">
									<div class="box box-primary">
										<div class="box-header with-border">
											<h4 id="barid" class='box-title'></h4>
										</div>
										<div class="box-body">
											<div id="ratiobar" style="height: 350px; margin: 0 auto;text-align:center;color:grey;font-size:16px;font-weight:bold" />
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
					<div class="chart tab-pane" id="monthCaseTab"
						style="position: relative">
						<div class="row">
							<div class="col-xs-12">
								<div class="box box-primary">
									<div class="box-header with-border">
										<h4 id="monthTitle" class='box-title'></h4>
									</div>
									<div class="box-body">
										<div id="monthline" style="height: 60px; margin: 0 auto"></div>
										<div id="monthcheckbar" style="height: 400px; margin: 0 auto"></div>
									</div>
								</div>
							</div>
							<div class="col-xs-12">
								<div class="col-lg-6 col-xs-6 no-padding">
									<div class="box box-primary">
										<div class="box-header with-border">
											<h4 id="monthPieTitle" class='box-title'></h4>
										</div>
										<div class="box-body">
											<div id="monthcheckpie" style="height: 350px;"></div>
										</div>
									</div>
								</div>
								<div class="col-lg-6 col-xs-6 no-padding">
									<div class="box box-primary">
										<div class="box-header with-border">
											<h4 id="monthBarTitle" class='box-title'></h4>
										</div>
										<div class="box-body">
											<div id="monthratiobar" style="height: 350px"></div>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<p:dialog widgetVar="dataDlg" header="数据维护" modal="true" id="dataDlg"
			width="1300" height="700" onHide="initDatas()">
			<h:form id="form">
				<div class="box box-solid with-border">
					<div class="box-header">
						<p:outputLabel value="年 ：" />
						<h:selectOneMenu value="#{checkPlanMaintenanceController.year}"
							style="width:100px;margin-right:20px;height:30px" id="yearId">
							<f:selectItem itemValue="0" itemLabel="全部" />
							<f:selectItems value="#{checkPlanMaintenanceController.years}" />
						</h:selectOneMenu>
						<p:outputLabel value="月：" />
						<h:selectOneMenu value="#{checkPlanMaintenanceController.month}"
							style="width:100px;margin-right:20px;height:30px" id="monthId">
							<f:selectItem itemLabel="全年总值" itemValue="0" />
							<f:selectItems value="#{checkPlanMaintenanceController.months}" />
							<f:selectItem itemLabel="所有" itemValue="13" />
						</h:selectOneMenu>
						<p:outputLabel value="省份 ：" />
						<h:selectOneMenu id="company_id"
							value="#{checkPlanMaintenanceController.subCompany}"
							style="width:130px;margin-right:20px;height:30px">
							<f:selectItem itemLabel="全部" itemValue="全部" />
							<f:selectItems
								value="#{checkPlanMaintenanceController.subCompanys}" />
						</h:selectOneMenu>
						<p:commandButton value="查询" icon="ui-icon-search"
							style="margin-right:10px"
							actionListener="#{checkPlanMaintenanceController.queryByCondition}"
							update="form:dataTable" />
						<p:commandButton value="重置" icon="ui-icon-refresh"
							style="margin-right:10px"
							actionListener="#{checkPlanMaintenanceController.initCondition()}"
							update="form:dataTable form:yearId form:monthId form:company_id" />
					</div>
				</div>
				<p:toolbar id="toolbar">
					<f:facet name="left">
						<p:commandButton value="新建" icon="fa fa-plus"
							actionListener="#{checkPlanMaintenanceController.preCreateCheckPlan}"
							oncomplete="PF('createDlg').show()"
							update="createDlg form:dataTable" />
						<p:commandButton value="编辑" icon="fa fa-pencil"
							actionListener="#{checkPlanMaintenanceController.editCheckPlan}"
							oncomplete="PF('editDlg').show()" update="editDlg form:dataTable "
							id="edit"
							disabled="#{checkPlanMaintenanceController.selectCheckPlan.id == null or (checkPlanMaintenanceController.selectCheckPlan.month == 0 and checkPlanMaintenanceController.selectCheckPlan.id != null)}" />
						<p:growl id="msgs" showDetail="true" />
						<p:commandButton value="删除" icon="fa fa-trash"
							update="msgs form:dataTable form:yearId form:company_id toolbar"
							id="delete"
							disabled="#{checkPlanMaintenanceController.selectCheckPlan.id == null or (checkPlanMaintenanceController.selectCheckPlan.month == 0 and checkPlanMaintenanceController.selectCheckPlan.id != null)}"
							actionListener="#{checkPlanMaintenanceController.deleteCheckPlan}">
							<p:confirm header="提示" message="确定删除该记录吗?" icon="ui-icon-alert" />
						</p:commandButton>
						<p:commandButton value="下载模板" ajax="false"
							icon="ui-icon-arrowthick-1-s"
							actionListener="#{checkPlanMaintenanceController.fileDownloadView()}">
							<p:fileDownload
								value="#{checkPlanMaintenanceController.templateFile}" />
						</p:commandButton>
						<p:commandButton id="newStatBtn" value="上传文件" icon="ui-icon-arrowthick-1-n"
							actionListener="#{checkPlanMaintenanceController.chooseEquipment}">
							<p:ajax event="dialogReturn"
								update="form:msgs form:dataTable form:yearId company_id"
								listener="#{checkPlanMaintenanceController.onSelectorChosen}" />
						</p:commandButton>
					</f:facet>
				</p:toolbar>
				<p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
					<p:commandButton value="是" type="button"
						styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
					<p:commandButton value="否" type="button"
						styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
				</p:confirmDialog>
				<p:dataTable value="#{checkPlanMaintenanceController.checkPlans}"
					var="act" paginator="true" id="dataTable" emptyMessage="无记录"
					rowKey="#{act.id}" rows="20" rowIndexVar="ite"
					selection="#{checkPlanMaintenanceController.selectCheckPlan}"
					paginatorTemplate="{Customization} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
					rowsPerPageTemplate="20,50,100" paginatorPosition="bottom"
					style="text-align:center;margin-top:3px">
					<f:facet name="{Customization}">
						<p:outputLabel value="总计：#{checkPlanMaintenanceController.checkPlans.size()} 条记录" style="margin-right:20px;" />
					</f:facet>
					<p:ajax event="rowSelectRadio" listener="#{checkPlanMaintenanceController.onRowSelect}" update="form:edit  form:delete" />
					<p:column selectionMode="single" width="60" style="text-align:center" />
					<p:column width="60" headerText="序号">
						<h:outputText value="#{ite+1}" />
					</p:column>
					<p:column headerText="省份">
						<p:outputLabel value="#{act.subCompany}" />
					</p:column>
					<p:column headerText="计划值">
						<p:outputLabel value="#{act.plan}" />
					</p:column>
					<p:column headerText="完成值">
						<p:outputLabel value="#{act.reality}" />
					</p:column>
					<p:column headerText="年">
						<p:outputLabel value="#{act.year}" />
					</p:column>
					<p:column headerText="月">
						<p:outputLabel value="#{act.month == 0 ? '全年总值': act.month}" />
					</p:column>
				</p:dataTable>
			</h:form>
		</p:dialog>

		<p:dialog widgetVar="createDlg" header="保护动作指标" width="350"
			height="250">
			<h:form id="createDlg">
				<p:toolbar>
					<f:facet name="left">
						<p:commandButton value="保存" icon="ui-icon-disk"
							actionListener="#{checkPlanMaintenanceController.saveCheckPlan}"
							update=":form:toolbar :form:msgs :form:dataTable :form:yearId :form:company_id"
							oncomplete="PF('createDlg').hide()" />
					</f:facet>
				</p:toolbar>
				<p:outputPanel style="text-align:center;">
					<p:panelGrid columns="2">
						<h:outputText value="省份" />
						<p:autoComplete style="width:100%"
							value="#{checkPlanMaintenanceController.checkPlan.subCompany}"
							completeMethod="#{checkPlanMaintenanceController.completeSubCompany}"
							dropdown="true" />
						<h:outputText value="计划值" />
						<p:inputText label="content" style="width:100%"
							value="#{checkPlanMaintenanceController.checkPlan.plan}">
						</p:inputText>
						<h:outputText value="完成值" />
						<p:inputText label="content" style="width:100%"
							value="#{checkPlanMaintenanceController.checkPlan.reality}">
						</p:inputText>
						<h:outputText value="年" />
						<p:inputText label="content" style="width:100%"  requiredMessage="请输入年份"  required = "true"
							value="#{checkPlanMaintenanceController.checkPlan.year}">
						</p:inputText>
						<h:outputText value="月" />
						<h:selectOneMenu 
							value="#{checkPlanMaintenanceController.checkPlan.month}"
							style="width:100%;margin-right:20px;height:30px">
							<f:selectItems value="#{checkPlanMaintenanceController.months}" />
						</h:selectOneMenu>
					</p:panelGrid>
				</p:outputPanel>
			</h:form>
		</p:dialog>

		<p:dialog widgetVar="editDlg" header="保护动作指标" width="350" height="250">
			<h:form id="editDlg">
				<p:toolbar>
					<f:facet name="left">
						<p:commandButton value="保存" icon="ui-icon-disk"
							actionListener="#{checkPlanMaintenanceController.saveCheckPlan}"
							update=":form:toolbar :form:msgs :form:dataTable :form:yearId :form:company_id"
							oncomplete="PF('editDlg').hide()" />
					</f:facet>
				</p:toolbar>
				<p:outputPanel style="text-align:center;">
					<p:panelGrid columns="2">
						<h:outputText value="省份" />
						<p:autoComplete style="width:100%"
							value="#{checkPlanMaintenanceController.checkPlan.subCompany}"
							completeMethod="#{checkPlanMaintenanceController.completeSubCompany}"
							dropdown="true" />
						<h:outputText value="计划值" />
						<p:inputText label="content" style="width:100%"
							value="#{checkPlanMaintenanceController.checkPlan.plan}">
						</p:inputText>
						<h:outputText value="完成值" />
						<p:inputText label="content" style="width:100%"
							value="#{checkPlanMaintenanceController.checkPlan.reality}">
						</p:inputText>
						<h:outputText value="年" />
						<p:inputText label="content" readonly="true" style="width:100%"
							value="#{checkPlanMaintenanceController.checkPlan.year}">
						</p:inputText>
						<h:outputText value="月" />
						<h:selectOneMenu
							value="#{checkPlanMaintenanceController.checkPlan.month}"
							style="width:100%;margin-right:20px;height:30px">
							<f:selectItems value="#{checkPlanMaintenanceController.months}" />
						</h:selectOneMenu>
					</p:panelGrid>
				</p:outputPanel>
			</h:form>
		</p:dialog>

		<h:inputHidden id="lineName" value="#{request.getParameter('selectName')}" />
	</ui:define>
	<ui:define name="contentend">
		<script src="#{request.contextPath}/resources/js/tables/mytable.js" />
		<script src="#{request.contextPath}/resources/js/mycharts/charts.js" />
		<script src="#{request.contextPath}/resources/plugins/echarts/echarts.js" />
		<script src="#{request.contextPath}/resources/plugins/datatables/jquery.dataTables.min.js" />
		<script src="#{request.contextPath}/resources/plugins/datatables/dataTables.bootstrap.min.js" />
		<script src="#{request.contextPath}/resources/js/array-util.js" />
		<script src="#{request.contextPath}/resources/js/mycharts/category2YLineChart.js" />
		<script src="#{request.contextPath}/resources/js/mycharts/timeline.js" />
		<script src="#{request.contextPath}/resources/js/mycharts/categoryBarChart.js" />
		<script src="#{request.contextPath}/resources/bootstrap/js/bootstrap-datetimepicker.min.js" />
		<script src="checkPlan.js" />
	</ui:define>
</ui:composition>